package se.study.io.nio;// $Id$

import java.nio.*;
/**
 * @Author:Tiger
 * @Date:2018/5/9 9:46
 * @Description:
 */
public class UseFloatBuffer {
    static public void main(String args[]) throws Exception {
        // 分配容量为10的浮点型缓冲区
        FloatBuffer buffer = FloatBuffer.allocate(10);

        for (int i = 0; i < buffer.capacity(); ++i) {
            float f = (float) Math.sin((((float) i) / 10) * (2 * Math.PI));
            buffer.put(f);
        }

        buffer.flip();

        while (buffer.hasRemaining()) {
            float f = buffer.get();
            System.out.println(f);
        }
    }
}
